import store from '@/store'

export default {
  imgerror: {
    inserted (dom, obj, vnode) {
      dom.src = dom.src || obj.value
      dom.onerror = function () {
        dom.src = obj.value
      }
    },
    componentUpdated (dom, obj) {
      dom.src = dom.src || obj.value
    },
    unbind (dom, obj) {
      dom.onerror = null
    }
  },
  control: {
    inserted (dom, obj) {
      if (!store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    },
    componentUpdated (dom, obj) {
      if (!store.state.user.userInfo.roles.points.includes(obj.value)) {
        dom.style.display = 'none'
      }
    }
  }
}
